﻿using System.Collections;
using System.Collections.Generic;
using System.Web.UI;
using System.Xml;
using visinia.SmartEngine;
using visinia.SmartEngine.Modules;

public partial class Modules_MenuLite : WebModule
{
    protected override void WebModuleRender(HtmlTextWriter output)
    {
        XmlDocument doc = new XmlDocument();
        string path = Server.MapPath(WebRoots.GetModulesRoot);
        doc.Load(path + "General/MenuLite/MenuData.xml");
        XmlNode root = doc.DocumentElement;
        IEnumerator ienum = root.GetEnumerator();
        XmlNode node;
        List<string> text = new List<string>();
        List<string> links = new List<string>();
        string CurrentPageUrl = Request.RawUrl;        
        while (ienum.MoveNext())
        {
            node = (XmlNode)ienum.Current;
            if (node.Attributes == null)// for a commented node
                continue;
            string title = node.Attributes["name"].Value;
            string url = node.Attributes["value"].Value;
            text.Add(title);
            if (url.StartsWith("http://"))
                links.Add(url);
            else            
                links.Add(WebRoots.GetWebRoot + url);            
        }        
        string data = WebHelpers.GenerateBulletedListHyperLinks(text.ToArray(), links.ToArray(), CurrentPageUrl);
        output.Write(data);
    }
}